//路由配置信息
//路由懒加载(高效)
export default [
    {
        path:'/home',
        component:()=>import('@/pages/Home/Home'),
        meta:{show:true}
    },
    {
        name: 'search',
        path:'/search/:keyword?',
        component:()=>import('@/pages/Search/Search'),
        meta:{show: true}
    },
    {
        path:'/login',
        component:()=>import('@/pages/Login/Login'),
        meta:{show: false}
    },
    {
        path:'/register',
        component:()=>import('@/pages/Register/Register'),
        meta:{show: false}
    },
    {
        path:'/Detail/:gid',
        component:()=>import('@/pages/Detail/Detail'),
        meta:{show: false}
    },
    {
        name: 'addcartsuccess',
        path:'/addcartsuccess',
        component:()=>import('@/pages/AddCartSuccess/AddCartSuccess'),
        meta:{show: true}
    },
    {
        path:'/shopcart',
        component:()=>import('@/pages/ShopCart/ShopCart'),
        meta:{show: true}
    },
    {
        path:'/trade',
        component: ()=>import('@/pages/Trade/Trade'),
        meta: {show:true},
        //路由独享守卫
        beforeEnter:(to,from,next)=>{
            if (from.path=='/shopcart'){
                next()
            }else {
                next(false)
            }
    }
    },
    {
        path:'/pay',
        component: ()=>import('@/pages/Pay/Pay'),
        meta: {show:true},
        //路由独享守卫
        beforeEnter:(to,from,next)=>{
            if (from.path=='/trade'){
                next()
            }else {
                next(false)
            }
        }
    },
    {
        path:'/paysuccess',
        component: ()=>import('@/pages/PaySuccess/PaySuccess'),
        meta: {show:true}
    },
    {
        path:'/center',
        component: ()=>import('@/pages/Center/Center'),
        meta: {show:true},
        //二级路由要么不写/，要么写全：'/center/myorder'
        children:[{
            path:'myorder',
            component:()=>import('@/pages/Center/myOrder/MyOrder'),
        },
            {
                path:'grouporder',
                component:()=>import('@/pages/Center/groupOrder/GroupOrder'),
            },
            {
                path: '',
                redirect:'myorder'
            }
     ]
    },
    //重定向
    {
        path:'*',
        redirect:'/home'
    }
]
